import 'dart:ui' as ui;

class ImageQueue {
  List<ui.Image> images = [];
  int currentIndex;

  ImageQueue(List<ui.Image> imageList) {
    images = imageList;
    currentIndex = 0;
  }

  ui.Image getCurrentBitmap() {
    if (images != null && images.length > 0) {
      ui.Image currentImage;
      if (currentIndex < images.length) {
        currentImage = images[currentIndex];
        updateIndex();
      } else {
        currentIndex = 0;
        currentImage = images[currentIndex];
      }
      return currentImage;
    }
    return null;
  }

  double getSpacing() {
    if (images != null && images.length > 0) {
      return images[currentIndex].width / 2;
    } else {
      return 0;
    }
  }

  ui.Image getFirstBitmap() {
    if (images != null && images.length > 0) {
      currentIndex = 0;
      return images[0];
    }
    return null;
  }

  bool isEmpty() {
    if (images != null && images.length > 0) {
      return false;
    } else {
      return true;
    }
  }

  void updateIndex() {
    if (currentIndex + 1 < images.length) {
      currentIndex++;
    } else {
      currentIndex = 0;
    }
  }
}
